<template>
    <el-select v-model="inValue" v-on="$listeners" v-bind="$attrs">
        <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
    </el-select>
</template>

<script>
import commonWifiMixin from '@/views/netWork/wifiSettings/mixins/commonWifiMixin';
export default {
    name: 'WiFiAuthType',
    mixins: [commonWifiMixin],
    props: {
        value: [String],
        wifiType: {
            type: String,
            default: ''
        }
    },
    data() {
        return {
            options: []
        };
    },
    computed: {
        inValue: {
            get: function () {
                return this.value;
            },
            set: function (newValue) {
                this.$emit('input', newValue);
            }
        }
    },
    methods: {
        async fetchData() {
            let result = '';

            let node = '';

            if (this.wifiType == '6G') {
                node = 'WIFI_6G_SUPPORT_ENCRYPTION';
            } else {
                node = 'wifi_support_encryption';
            }

            const res = await this.$getNodeFromServer(...[node]);

            if (res && res[node]) {
                result = res[node];
            }

            if (result) {
                this.options = this.getSecurityType(result);
            }
        }
    },
    created() {
        this.fetchData();
    }
};
</script>

<style lang="less" scoped></style>
